home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol2 / Archives / Plain / mj91 / ASL / aslcode.txt < prev    next >
Encoding:
Text File  |  1991-06-12  |  14.2 KB  |  474 lines

  1. ;/* simpleFR.c - Execute me to compile me with SASC 5.10
  2. LC -b1 -cfistq -v -y -j73 simpleFR.c
  3. Blink FROM LIB:c.o,simpleFR.o TO simpleFR LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6.  
  7. /*(c)  Copyright 1991 Commodore-Amiga, Inc.   All rights reserved.
  8. The information contained herein is subject to change without notice,
  9. and is provided "as is" without warranty of any kind, either expressed
  10. or implied.  The entire risk as to the use of this information is
  11. assumed by the user.
  12. */
  13.  
  14. #include <clib/asl_protos.h>
  15. #include <clib/exec_protos.h>
  16. #include <clib/alib_stdio_protos.h>
  17. #include <dos/dosasl.h>
  18. #include <exec/libraries.h>
  19.  
  20. #ifdef LATTICE
  21. int CXBRK(void) { return(0); }  /* Disable Lattice CTRL/C handling */
  22. int chkabort(void) { return(0); }  /* really */
  23. #endif
  24.  
  25. UBYTE *vers = "\0$VER: simpleFR 1.1";
  26.  
  27. void main(void);
  28.  
  29. #define MYLEFTEDGE 0
  30. #define MYTOPEDGE  0
  31. #define MYWIDTH    320
  32. #define MYHEIGHT   400
  33.  
  34. struct Library *AslBase;
  35.  
  36. struct TagItem frtags[] =
  37. {
  38.     ASL_Hail,       (ULONG)"The RKM file requester",
  39.     ASL_Height,     MYHEIGHT,
  40.     ASL_Width,      MYWIDTH,
  41.     ASL_LeftEdge,   MYLEFTEDGE,
  42.     ASL_TopEdge,    MYTOPEDGE,
  43.     ASL_OKText,     (ULONG)"O KAY",
  44.     ASL_CancelText, (ULONG)"not OK",
  45.     ASL_File,       (ULONG)"asl.library",
  46.     ASL_Dir,        (ULONG)"libs:",
  47.     TAG_DONE
  48. };
  49.  
  50.  
  51.  
  52. void main()
  53. {
  54.  
  55.     struct FileRequester *fr;
  56.  
  57.     if (AslBase = OpenLibrary("asl.library", 36L))
  58.     {
  59.         if (fr = (struct FileRequester *)
  60.             AllocAslRequest(ASL_FileRequest, frtags))
  61.         {
  62.             /* Application body, blah, blah,... */
  63.             
  64.             /* Application need a requester */ 
  65.             if (AslRequest(fr, 0L))
  66.                 printf("file choice = %s%s\n", fr->rf_Dir, fr->rf_File);
  67.             else
  68.                 printf("User Cancelled\n");
  69.  
  70.             /* More application body, blah, blah... */
  71.         }
  72.         
  73.         /* Don't need any more requesters, better 
  74.         ** give the requester structure back. 
  75.         */
  76.         FreeAslRequest(fr);
  77.     }
  78.     CloseLibrary(AslBase);
  79. }
  80.  
  81.  
  82.  
  83.  
  84.  
  85. ;/* filepat.c - Execute me to compile me with SASC 5.10
  86. LC -b1 -cfistq -v -y -j73 filepat.c
  87. Blink FROM LIB:c.o,filepat.o TO filepat LIBRARY LIB:LC.lib,LIB:Amiga.lib
  88. quit
  89. */
  90.  
  91. /*(c)  Copyright 1991 Commodore-Amiga, Inc.   All rights reserved.
  92. The information contained herein is subject to change without notice,
  93. and is provided "as is" without warranty of any kind, either expressed
  94. or implied.  The entire risk as to the use of this information is
  95. assumed by the user.
  96. */
  97.  
  98. #include <clib/asl_protos.h>
  99. #include <clib/exec_protos.h>
  100. #include <clib/intuition_protos.h>
  101. #include <clib/alib_stdio_protos.h>
  102. #include <workbench/startup.h>
  103. #include <intuition/intuition.h>
  104. #include <intuition/screens.h>
  105. #include <graphics/displayinfo.h>
  106. #include <exec/libraries.h>
  107.  
  108. #ifdef LATTICE
  109. int CXBRK(void) { return(0); }  /* Disable Lattice CTRL/C handling */
  110. int chkabort(void) { return(0); }  /* really */
  111. #endif
  112.  
  113. UBYTE *vers = "\0$VER: filepat 1.0";
  114.  
  115. void main(void);
  116.  
  117. struct Library *AslBase;
  118. struct IntuitionBase *IntuitionBase;
  119. struct Screen *screen;
  120. struct Window *window;
  121.  
  122. struct WBArg *wbargs;
  123.  
  124. LONG x;
  125.  
  126.  
  127. void main()
  128. {
  129.  
  130.     struct FileRequester *fr;
  131.  
  132.     if (AslBase = OpenLibrary("asl.library", 36L))
  133.     {
  134.         if (IntuitionBase = (struct IntuitionBase *)
  135.                 OpenLibrary("intuition.library", 36L))
  136.         {
  137.             if (screen = (struct Screen *)OpenScreenTags(NULL, 
  138.                     SA_DisplayID, HIRESLACE_KEY,
  139.                     SA_Title, "ASL Test Screen",
  140.                     TAG_END))
  141.             {
  142.                 if (window = (struct Window *)OpenWindowTags(NULL, 
  143.                         WA_CustomScreen, screen, 
  144.                         WA_Title, "ASL Test Window", 
  145.                         WA_Flags, WINDOWDEPTH | WINDOWDRAG,
  146.                         TAG_END))
  147.                 {
  148.                     if (fr = (struct FileRequester *)
  149.                         AllocAslRequestTags(ASL_FileRequest, 
  150.                             ASL_Hail, (ULONG)"RKM File Requester, FilePat",
  151.                             ASL_Dir,  (ULONG)"libs:",
  152.                             ASL_File, (ULONG)"asl.library",
  153.  
  154.                             /* The initial pattern string for the 
  155.                             ** pattern gadget.
  156.                             */
  157.                             ASL_Pattern, (ULONG)"~(rexx#?|math#?)",
  158.                             
  159.                             /* turn on multiselection and the pattern
  160.                             ** matching gadget.
  161.                             */
  162.                             ASL_FuncFlags, FILF_MULTISELECT | FILF_PATGAD,
  163.                             
  164.                             /* This requester is associated with this
  165.                             ** window (and uses its message port). 
  166.                             */
  167.                             ASL_Window, window,
  168.                             TAG_DONE))
  169.                     {
  170.                         /* Application code body...*/
  171.                         
  172.                         /* Put up file requester */
  173.                         if (AslRequest(fr, 0L))
  174.                         {
  175.                             /* If the file requester's rf_NumArgs field
  176.                             ** is not zero, the user multiselected. The
  177.                             ** number of files is stored in rf_NumArgs.
  178.                             */
  179.                             if (fr->rf_NumArgs)
  180.                             {
  181.                                 /* rf_ArgList is an array of WBArg structures
  182.                                 ** (defined in <workbench/startup.h>).  
  183.                                 ** Each entry in the WBArg array corresponds
  184.                                 ** to one of the files the user selected
  185.                                 ** (the entries are in alphabetical order).
  186.                                 */ 
  187.                                 wbargs = fr->rf_ArgList;
  188.                                 
  189.                                 /* The user multiselected, step through
  190.                                 ** the list of selected files. 
  191.                                 */
  192.                                 for ( x=0;  x < fr->rf_NumArgs;  x++ )
  193.                                     printf("Argument %d - %s%s\n", x, 
  194.                                         fr->rf_Dir, wbargs[x].wa_Name);
  195.                             }
  196.                             else
  197.                                 /* The user didn't multiselect, use the 
  198.                                 ** normal way to get the file name.
  199.                                 */
  200.                                 printf("%s%s\n", fr->rf_Dir, fr->rf_File);
  201.                         }
  202.                         /* More application code body... */
  203.  
  204.                         /* Done with the FileRequester, better return it */
  205.                         FreeAslRequest(fr);
  206.                     }
  207.                     CloseWindow(window);
  208.                 }
  209.                 CloseScreen(screen);
  210.             }
  211.             CloseLibrary(IntuitionBase);
  212.         }
  213.         CloseLibrary(AslBase);
  214.     }
  215. }
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224. ;/* fontreq.c - Execute me to compile me with Lattice 5.10
  225. LC -b1 -cfistq -v -y -j73 fontreq.c
  226. Blink FROM LIB:c.o,fontreq.o TO fontreq LIBRARY LIB:LC.lib,LIB:Amiga.lib
  227. quit
  228. */
  229.  
  230. /*(c)  Copyright 1991 Commodore-Amiga, Inc.   All rights reserved.
  231. The information contained herein is subject to change without notice,
  232. and is provided "as is" without warranty of any kind, either expressed
  233. or implied.  The entire risk as to the use of this information is
  234. assumed by the user.
  235. */
  236.  
  237.  
  238. #include <clib/asl_protos.h>
  239. #include <clib/exec_protos.h>
  240. #include <clib/alib_stdio_protos.h>
  241. #include <exec/libraries.h>
  242.  
  243. #ifdef LATTICE
  244. int CXBRK(void) { return(0); }  /* Disable Lattice CTRL/C handling */
  245. int chkabort(void) { return(0); }  /* really */
  246. #endif
  247.  
  248.  
  249. UBYTE *vers = "\0$VER: fontreq 1.0";
  250.  
  251. void main(void);
  252. struct Library *AslBase, *UtilityBase;
  253.  
  254. /* The replacement strings for the "mode" cycle gadget.  The
  255. ** first string is the cycle gadget's label.  The other strings
  256. ** are the actual strings that will appear on the cycle gadget.
  257. */
  258. UBYTE *modelist[] = 
  259. {
  260.     "RKM Modes",
  261.     "Mode 0",
  262.     "Mode 1",
  263.     "Mode 2",
  264.     "Mode 3",
  265.     "Mode 4",
  266.     "Mode 5",
  267.     "Mode 6",
  268.     "Mode 7",
  269.     "Mode 8",
  270.     "Mode 9",
  271.     NULL
  272. };
  273.     
  274.  
  275. void main()
  276. {
  277.  
  278.     struct FontRequester *fr;
  279.  
  280.     if (AslBase = OpenLibrary("asl.library", 36L))
  281.     {
  282.  
  283.         if (fr = (struct FontRequester *)
  284.             AllocAslRequestTags(ASL_FontRequest, 
  285.                 /* tell the requester to use my custom mode names */
  286.                 ASL_ModeList, modelist,
  287.                 
  288.                 /* Supply initial values for requester */
  289.                 ASL_FontName, (ULONG)"topaz.font",
  290.                 ASL_FontHeight, 11L,
  291.                 ASL_FontStyles, FSF_BOLD | FSF_ITALIC,
  292.                 ASL_FrontPen,  0x00L,
  293.                 ASL_BackPen,   0x01L,
  294.                 
  295.                 /* Only display font sizes between 8 and
  296.                 ** 14, inclusive. */
  297.                 ASL_MinHeight, 8L,
  298.                 ASL_MaxHeight, 14L,
  299.                 
  300.                 /* Give us all the gadgetry, but only display
  301.                 ** fixed width fonts */
  302.                 ASL_FuncFlags, FONF_FRONTCOLOR | FONF_BACKCOLOR | 
  303.                     FONF_DRAWMODE | FONF_STYLES | FONF_FIXEDWIDTH,
  304.                 TAG_DONE))
  305.         {
  306.             /* application code here... */
  307.             
  308.             
  309.             /* Pop up the requester */
  310.             if (AslRequest(fr, 0L))
  311.             {
  312.                 /* The user selected something,  report their choice */
  313.                 printf("%s\n  YSize = %d  Style = 0x%x   Flags = 0x%x\n"
  314.                        "  FPen = 0x%x   BPen = 0x%x   DrawMode = 0x%x\n", 
  315.                                fr->fo_Attr.ta_Name,
  316.                                fr->fo_Attr.ta_YSize, 
  317.                                fr->fo_Attr.ta_Style,
  318.                                fr->fo_Attr.ta_Flags,
  319.                                fr->fo_FrontPen,
  320.                                fr->fo_BackPen,
  321.                                fr->fo_DrawMode);
  322.             }
  323.             else
  324.                 /* The user cancelled the requester, or
  325.                 ** some kind of error occured preventing
  326.                 ** the requester from opening. */
  327.                 printf("Request Cancelled\n");
  328.  
  329.             /* more application code here ...*/
  330.             
  331.             FreeAslRequest(fr);
  332.         }
  333.         CloseLibrary(AslBase);
  334.     }
  335. }
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345. ;/* filehook.c - Execute me to compile me with Lattice 5.10
  346. LC -b1 -cfistq -v -y -j73 filehook.c
  347. Blink FROM LIB:c.o,filehook.o TO filehook LIBRARY LIB:LC.lib,LIB:Amiga.lib
  348. quit
  349. */
  350.  
  351. /*(c)  Copyright 1991 Commodore-Amiga, Inc.   All rights reserved.
  352. The information contained herein is subject to change without notice,
  353. and is provided "as is" without warranty of any kind, either expressed
  354. or implied.  The entire risk as to the use of this information is
  355. assumed by the user.
  356. */
  357.  
  358.  
  359. #include <clib/asl_protos.h>
  360. #include <clib/exec_protos.h>
  361. #include <clib/dos_protos.h>
  362. #include <clib/intuition_protos.h>
  363. #include <clib/alib_stdio_protos.h>
  364. #include <dos/dosasl.h>
  365. #include <intuition/intuition.h>
  366. #include <exec/libraries.h>
  367.  
  368. #ifdef LATTICE
  369. int CXBRK(void) { return(0); }  /* Disable Lattice CTRL/C handling */
  370. int chkabort(void) { return(0); }  /* really */
  371. #endif
  372.  
  373. #define DESTPATLENGTH 20
  374.  
  375. UBYTE *vers = "\0$VER: filehook 1.0";
  376.  
  377. void main(void);
  378.  
  379. struct Library *AslBase;
  380. struct IntuitionBase *IntuitionBase;
  381. struct Window *window;
  382.  
  383. CPTR HookFunc();
  384.  
  385. /* this is the pattern matching string that the hook function uses */
  386. UBYTE *sourcepattern = "(#?.info)";
  387. UBYTE pat[DESTPATLENGTH];
  388.  
  389.  
  390. void main()
  391. {
  392.  
  393.     struct FileRequester *fr;
  394.  
  395.     /* This is a dos.library function that turns a pattern matching
  396.     ** string into something the DOS pattern matching functions
  397.     ** can understand.
  398.     */
  399.     ParsePattern(sourcepattern, pat, DESTPATLENGTH);
  400.  
  401.     if (AslBase = OpenLibrary("asl.library", 36L))
  402.     {
  403.         if (IntuitionBase = (struct IntuitionBase *)
  404.                     OpenLibrary("intuition.library", 36L))
  405.         {
  406.             /* open a window that gets ACTIVEWINDOW events */
  407.             if (window = (struct Window *)OpenWindowTags(NULL, 
  408.                     WA_Title, "ASL Hook Function Example", 
  409.                     WA_IDCMP, IDCMP_ACTIVEWINDOW,
  410.                     WA_Flags, WINDOWDEPTH,
  411.                     TAG_END))
  412.             {
  413.                 if (fr = AllocFileRequest())
  414.                 {
  415.                     /* application body here... */
  416.                     
  417.                     
  418.                     if (AslRequestTags(fr, 
  419.                         ASL_Window, window,
  420.                         ASL_TopEdge, 0L,
  421.                         ASL_Height, 200L,
  422.                         ASL_Hail, (ULONG)"Pick an icon to save",
  423.                         ASL_HookFunc, (ULONG)HookFunc,
  424.                         ASL_FuncFlags, FILF_DOWILDFUNC | FILF_DOMSGFUNC | FILF_SAVE,
  425.                         ASL_OKText, (ULONG)"Save",
  426.                         TAG_DONE))
  427.                     {
  428.                         printf("You picked %s%s\n", fr->rf_Dir, fr->rf_File);
  429.                     }
  430.                     
  431.                     /* more application body here */
  432.                     
  433.                     FreeFileRequest(fr);
  434.                 }
  435.                 CloseWindow(window);
  436.             }
  437.             CloseLibrary(IntuitionBase);
  438.         }
  439.         CloseLibrary(AslBase);
  440.     }
  441. }
  442.  
  443.  
  444.  
  445. CPTR HookFunc(LONG type, CPTR obj, struct FileRequester *fr)
  446. {
  447.     static BOOL returnvalue;
  448.     switch(type)
  449.     {
  450.         case FILF_DOMSGFUNC:
  451.         /* We got a message meant for the window */
  452.             printf("You activated the window\n");
  453.             return(obj);
  454.             break;
  455.         case FILF_DOWILDFUNC:
  456.         /* We got an AnchorPath structure, should
  457.         ** the requester display this file? */
  458.         
  459.             /* MatchPattern() is a dos.library function that 
  460.             ** compares a matching pattern (parsed by the
  461.             ** ParsePattern() DOS function) to a string and
  462.             ** returns true if they match. */
  463.             returnvalue = MatchPattern(pat, 
  464.                     ((struct AnchorPath *)obj)->ap_Info.fib_FileName);
  465.             
  466.             /* we have to negate MatchPattern()'s return value 
  467.             ** because the file requester expects a zero for 
  468.             ** a match not a TRUE value */
  469.             return( (CPTR)(! returnvalue) );
  470.             break;
  471.     }
  472. }
  473.  
  474.